package com.fulihui.wgj.admin.integration.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.fulihui.common.result.rpc.BaseResult;
import com.fulihui.wgj.admin.integration.UserLoginClient;
import com.fulihui.wgj.facade.request.user.UserLoginPasswordRequest;
import com.fulihui.wgj.facade.request.user.UserLoginRequest;
import com.fulihui.wgj.facade.service.user.UserLoginService;
import org.springframework.stereotype.Component;

/**
 * 用户登录
 *
 * @author: Levon
 * @version: v 0.1 2018-06-14 14:18
 */
@Component("userLoginServiceClient")
public class UserLoginClientImpl implements UserLoginClient {

    @Reference(version = "1.0.0")
    private UserLoginService userLoginService;

    @Override
    public BaseResult login(String loginId, String password) {
        UserLoginRequest userLoginRequest = new UserLoginRequest();
        userLoginRequest.setLoginId(loginId);
        userLoginRequest.setPassword(password);
        return userLoginService.login(userLoginRequest);
    }

    @Override
    public BaseResult register(String loginId, String password) {
        UserLoginRequest userLoginRequest = new UserLoginRequest();
        userLoginRequest.setLoginId(loginId);
        userLoginRequest.setPassword(password);
        return userLoginService.register(userLoginRequest);
    }

    @Override
    public BaseResult updatePassword(String loginId, String password, String oldPassword) {
        UserLoginPasswordRequest request = new UserLoginPasswordRequest();
        request.setLoginId(loginId);
        request.setNewPassword(password);
        request.setOldPassword(oldPassword);
        return userLoginService.updatePassword(request);
        
    }
}
